using UnityEngine;
using System.Collections;

public class Respawn : MonoBehaviour {

    public bool m_bActive = false;

    GameObject[] m_ArrayRespawn;

    GameObject m_CharacterController;
	void Start () {
        m_CharacterController = GameObject.FindGameObjectWithTag("Player");
        m_ArrayRespawn = GameObject.FindGameObjectsWithTag("Respawn");
	}
	
	// Update is called once per frame
	void Update () {
	
	}

    void OnTriggerEnter(Collider col)
    {
        if (col.collider == m_CharacterController.collider)
        {
            for (int index = 0; index < m_ArrayRespawn.Length; ++index)
            {
                if (m_ArrayRespawn[index].GetComponent<Respawn>().m_bActive)
                {
                    m_ArrayRespawn[index].GetComponent<Respawn>().m_bActive = false;
                }
            }

            if (!m_bActive)
            {
                m_bActive = true;
            }
        }
    }
}
